package com.ymttest.database.sqlwapper.shenqisettlement;

import java.math.BigDecimal;
import java.util.List;

import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.shenqisettlement.Withdraw;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

public class WithdrawWrapper {

	SqlManager manager;

    public WithdrawWrapper() {
        manager = new SqlManager("shenqisettlement");
    }
    
    @SuppressWarnings("unchecked")
	public Withdraw selectByPrimaryKey(String withdrawId) {
    	
    	List<Withdraw> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.shenqisettlement.WithdrawMapper.selectByPrimaryKey",
                        withdrawId);
        manager.commit();
        
		if (result.size() == 0) {
			Logger.comment("withdraw没有数据");
		}
		
		return result.get(0);
    }
    
    public int insert(Withdraw withdrawPo) {
    	
    	int result = manager.insert("com.ymttest.database.mapping.shenqisettlement.WithdrawMapper.insert", withdrawPo);
    	
    	manager.commit();
    	
    	return result;
    }
    
    public static void main(String[] args) {
    	
    	WithdrawWrapper wrapper = new WithdrawWrapper();
    	
    	Withdraw withdrawPo = new Withdraw();
    	
    	withdrawPo.setWithdraw_id("autotest" + TestDataManager.randomStr(20));
    	withdrawPo.setUser_id(500078247L);
    	withdrawPo.setBank_account_number("autotest_bank_account_number");
    	withdrawPo.setBank_account_currency("autotest_bank_account_currency");
    	withdrawPo.setBank_account_name("autotest_bank_account_name");
    	withdrawPo.setBank_name("autotest_bank_name");
    	withdrawPo.setWithdraw_status(1);
    	withdrawPo.setAccount_status(1);
    	withdrawPo.setCountry("USA");
    	withdrawPo.setBatch_withdraw_id("autotest" + TestDataManager.randomStr(20));
    	withdrawPo.setReal_withdraw_amount(BigDecimal.ONE);
    	withdrawPo.setApply_withdraw_amount(BigDecimal.TEN);
    	withdrawPo.setWithdraw_fee_amount(BigDecimal.ONE);
    	withdrawPo.setTe_receive_amount(BigDecimal.ONE);
    	withdrawPo.setTe_receive_currency("USD");
    	withdrawPo.setWithdraw_fee_amount_usd(BigDecimal.TEN);
    	withdrawPo.setTe_rate(BigDecimal.ONE);
    	withdrawPo.setRemark(null);
    	withdrawPo.setAdd_time(YMTDateUtil.getDate());
    	withdrawPo.setUpdate_time(YMTDateUtil.getDate());
    	withdrawPo.setAccount_type(1);
    	withdrawPo.setExchange_fee_rate(BigDecimal.ONE);
    	withdrawPo.setExchange_fee_amount(BigDecimal.TEN);
    	withdrawPo.setApply_withdraw_currency("USD");
    	withdrawPo.setAccount_deduct_time(null);
    	withdrawPo.setAccount_refund_time(null);
    	
    	wrapper.insert(withdrawPo);
    }
}
